﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Globalization;
using System.Windows.Media;
using ReporterEngine.Model;

namespace ReporterControlLibrary.Converters
{
    [ValueConversion(typeof(string), typeof(Visibility))]
    public class StringLengthToVisibilityConverter : IValueConverter
    {
        public int SourceValue { get; set; }
        public Visibility MatchVisibility { get; set; }
        public Visibility MisMatchVisibility { get; set; }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || (value.ToString().Length == SourceValue))
                return MatchVisibility;

            return MisMatchVisibility;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
